#include "zhan.h"

void kuorong(zhanbiao* s)
{
	int a =  (s->kongjian) * 2*4;
	_int* s1 = (_int*)realloc(s->a, a);
	if (s1 == NULL)
	{
		return;
	}
	s->a = s1;
	s->kongjian = a;
}
void chushizhanbiao(zhanbiao* s)
{
	s->a = (_int*)malloc(sizeof(_int)*4);
	s->kongjian = 4;
	s->youxiao = 0;
}
void shanzhanbiao(zhanbiao* s)
{
	assert(s->a);

	free(s->a);
	s->a = NULL;
	s->kongjian = 0;
	s->youxiao = 0;
}
void ruzhanbiao(zhanbiao* s, int x)
{
	assert(s->a);
	if (s->youxiao == s->kongjian)
		kuorong( s);
	s->a[s->youxiao] = x;
	s->youxiao++;

}
void chuzhanbiao(zhanbiao* s)
{
	assert(s->a);
	assert(s->youxiao);
	s->youxiao--;

}
int lazhanbiao(zhanbiao* s)
{
	assert(s->youxiao);
	return s->a[s->youxiao-1];
}